package com.sense.kukoo.biz_media.adapter

import com.sense.kukoo.common.media.bean.LocalMediaListItemBean
import com.sense.kukoo.common.repo.bean.MediaListItemBean
import com.sense.kukoo.common.wiget.adapter.MultiItemAdapter
import com.sense.kukoo.biz_media.adapter.provider.MediaListItemProvider

class MediaListAdapter(
    data: ArrayList<MediaListItemBean>,
    val listener: MediaListListener,
):
    MultiItemAdapter<MediaListItemBean>(data) {

    val mProvider: MediaListItemProvider

    init {
        mProvider = MediaListItemProvider(listener)
        addItemProvider(mProvider)
    }

    override fun getItemType(data: MutableList<MediaListItemBean>, position: Int): Int {
        return data.get(position).type
    }

    interface MediaListListener{
        fun onItemClick(bean: MediaListItemBean, position: Int)
    }

    fun setCurrentMusic(music: LocalMediaListItemBean){
        mProvider.setCurrentMusic(music)
        notifyDataSetChanged()
    }
}